package com.acwing.partition9;

import java.io.*;

/**
 * @author `RKC`
 * @date 2021/11/30 20:20
 */
public class AC895最长上升子序列 {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] s = reader.readLine().split(" ");
        int n = Integer.parseInt(s[0]);
        int[] nums = new int[n];
        s = reader.readLine().split(" ");
        for (int i = 0; i < s.length; i++) nums[i] = Integer.parseInt(s[i]);
        writer.write(dynamicProgramming(nums) + "\n");
        writer.flush();
    }

    private static int dynamicProgramming(int[] nums) {
        int[] dp = new int[nums.length];
        for (int i = 0; i < dp.length; i++) dp[i] = 1;
        int ans = 0;
        for (int j = 1; j < nums.length; j++) {
            for (int i = 0; i < j; i++) {
                if (nums[i] < nums[j]) dp[j] = Math.max(dp[j], dp[i] + 1);
                ans = Math.max(ans, dp[j]);
            }
        }
        return ans;
    }
}
